SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROC [dbo].[PUspevKPThemeINSERTTheme]
@ik_upContent INT,
@ik_zach INT,
@Options NUMERIC(4,0)=NULL,
@KPTheme VARCHAR(255)
AS
DECLARE @Temp INT;
SET @Temp=(select idUspevDocs from UspevDocument WHERE ik_upContent=@ik_upContent AND @ik_zach=ik_zach);
IF(@Temp is NULL)
BEGIN
EXEC PUspevDocumentINSERT @ik_zach,@ik_upContent;
SET @Temp=@@IDENTITY; 
END
INSERT INTO UspevKPTheme
(idUspevDocs,Options,KPTheme,DateReg)
VALUES
(@Temp,@Options,@KPTheme, NULL)
GO
